package com.taotao.module.bigdata.consumer.conf;

import com.corundumstudio.socketio.Configuration;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.common.serialization.StringSerializer;


import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public class PropertiesConf {
    private static Properties properties = BaseEnviromentConf.singletonEnvironment();

    private PropertiesConf() {
    }

    private static class ConsumerConfHolder {
        private static Map MAP = consumerConfigs();
    }

    public static Map<String, Object> consumerSingleConf() {
        return ConsumerConfHolder.MAP;
    }


    private static Map<String, Object> consumerConfigs() {

        final Map<String, Object> objectMap = new HashMap<>();
        objectMap.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, properties.getProperty("kafka_cluster"));
        objectMap.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
        objectMap.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class); //必须要配置否则启动报错
//        objectMap.put(ProducerConfig.AUTO_OFFSET_RESET_CONFIG, "latest");  //consumer 消费的顺序
        return objectMap;
    }

    private static Configuration nettyWebSocketConfigs() {
        Configuration config = new Configuration();
        config.setHostname(properties.getProperty("nettySocket"));
        config.setPort(Integer.valueOf(properties.getProperty("socket.port")));
        return config;
    }

}
